package com.tbq.tbqj_ggl.windows


import android.app.Activity
import android.view.View
import android.widget.ImageView
import com.tbq.sdk.L
import com.tbq.sdk.TBQ
import com.tbq.sdk.TBQ_V
import com.tbq.tbqj_ggl.R
import com.tbq.tbqj_ggl.app.AppBasePopupWindow
import com.tbq.tbqj_ggl.utils.ScreenUtil
import com.zxy.tiny.Tiny
import java.util.*


/**
 * Created by hais1992 on 2017/4/7/007.
 */

class ScratchGameWinWindows(activity: Activity) : AppBasePopupWindow(activity,
        if (TBQ.get("KEY_IS_MOBILE") == "1") R.layout.mobile_windows_scratch_game_win else R.layout.windows_scratch_game_win) {
    private var image_ljlq: ImageView? = null

    override fun showCenter() {
        if (TBQ.get("KEY_IS_MOBILE") != "1") {
            val options = Tiny.FileCompressOptions()
            options.quality = 50    //质量
            options.isKeepSampling = true   //保存默认宽高
            options.outfile = "/sdcard/TBQ_FILE/Screenshot/${TBQ.get(TBQ_V.KEY_RAFFLE_TICKET_ID)}_Game_${TBQ.get("KEY_ADMIN_ID")}.jpg"
            Tiny.getInstance().source(ScreenUtil.snapShotWithStatusBar(activity)).asFile().withOptions(options).compress { isSuccess, outfile ->
                L.e("GGL", "图片处理结果：$isSuccess,$outfile")
            }
        }
        super.showCenter()
    }

    override fun drawEnd(v: View) {
        image_ljlq = v.findViewById(R.id.image_ljlq) as ImageView
        image_ljlq!!.setOnClickListener(this)
    }


    override fun onClick(view: View) {
        when (view.id) {
            R.id.image_ljlq -> TBQ.openTBQ(activity, true, 0)
            else -> super.onClick(view)
        }
    }
}
